package com.jboost.modules.app;

import com.jboost.common.util.DySmsEnum;
import com.jboost.common.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@Slf4j
@Component
public class JBoostAppRunner {

    /**
     * 机构账号开通短信通知
     */
    @Value("${jeecg.sms.businessAccountTemplate.templateCode}")
    private String newTemplateCode;
    @Value("${jeecg.sms.businessAccountTemplate.signName}")
    private String newSignName;
    @Value("${jeecg.sms.businessAccountTemplate.keys}")
    private String newKeys;

    /**
     * 发验证码短信
     */
    @Value("${jeecg.sms.codeTemplate.templateCode}")
    private String codeTemplateCode;
    @Value("${jeecg.sms.codeTemplate.signName}")
    private String codeSignName;
    @Value("${jeecg.sms.codeTemplate.keys}")
    private String codeKeys;

    @Value("${spring.profiles.active}")
    private String env;
    @Resource
    private RedisUtil redisUtil;


    @PostConstruct
    public void init() throws Exception {
        log.info("**********模块启动初始化操作**************");

        /**
         * 短信
         */
        DySmsEnum.BUSINESS_ACCOUNT.setSignName(newSignName);
        DySmsEnum.BUSINESS_ACCOUNT.setTemplateCode(newTemplateCode);
        DySmsEnum.BUSINESS_ACCOUNT.setKeys(newKeys);

        DySmsEnum.GET_CODE.setSignName(newSignName);
        DySmsEnum.GET_CODE.setTemplateCode(newTemplateCode);
        DySmsEnum.GET_CODE.setKeys(newKeys);
        DySmsEnum.MEMBER_LOGIN_TEMPLATE_CODE.setSignName(codeSignName);
        DySmsEnum.MEMBER_LOGIN_TEMPLATE_CODE.setTemplateCode(codeTemplateCode);
        DySmsEnum.MEMBER_LOGIN_TEMPLATE_CODE.setKeys(codeKeys);
    }
}
